This page last changed on Apr 05, 2006 by dblasby.
Roads
 | process
(a) make a temporary table of all the road
(b) update so that null names are "" (this causes problems with the concatenate operator (||) )
(c) calculate lengths in meters |
 | Alternative names
Currently, we are not dealing with alternative names.
UPDATE: We're now dealing with alternative names – see below |
CREATE TABLE roads_tmp AS
SELECT wkb_geometry as the_geom, cfcc,
fedirp ,fename ,fetype ,fedirs ,
module,
tlid,
substring(cfcc from 1 for 1) as cfcc_1,
substring(cfcc from 2 for 1) as cfcc_2,
substring(cfcc from 3 for 1) as cfcc_3
FROM completechain
WHERE substring(cfcc for 1) = 'A' or substring(cfcc for 1) = 'P';
-- shouldnt make any changes
update roads_tmp set fedirp ='' where fedirp isnull;
update roads_tmp set fename ='' where fename isnull;
update roads_tmp set fetype ='' where fetype isnull;
update roads_tmp set fedirs ='' where fedirs isnull;
--make a easy-to-label name
ALTER TABLE roads_tmp add column name text;
UPDATE roads_tmp SET name =trim( both ' ' from fedirp || ' ' || fename || ' ' || fetype || ' '|| fedirs) ;
-- lengths
ALTER TABLE roads_tmp add column length_m float8;
update roads_tmp set length_m =
length2d_spheroid (the_geom, 'SPHEROID["GRS_1980",6378137,298.257222101]' )
;
CREATE TABLE roads AS
SELECT the_geom, cfcc, cfcc_1,cfcc_2,cfcc_3,module, tlid, name, length_m
FROM roads_tmp;
CREATE INDEX roads_idx_module on roads (module);
CREATE INDEX roads_idx_moduleid on roads (module,tlid);
CREATE INDEX roads_idx_spatial on roads using gist (the_geom gist_geometry_ops);
VACUUM ANALYSE roads;
INSERT INTO geometry_columns values ('','public','roads','the_geom',2,1,'GEOMETRY');
DROP TABLE roads_tmp;
 | Missing
The roads layer does not contain address information (in completechains) nor the under/overpass data (in overunder). |
Railroads
Process is exactly the same as with roads.
CREATE TABLE railroads_tmp AS
SELECT wkb_geometry as the_geom, cfcc,
fedirp ,fename ,fetype ,fedirs ,
module,
tlid,
substring(cfcc from 1 for 1) as cfcc_1,
substring(cfcc from 2 for 1) as cfcc_2,
substring(cfcc from 3 for 1) as cfcc_3
FROM completechain
WHERE substring(cfcc for 1) = 'B' ;
-- shouldnt make any changes
update railroads_tmp set fedirp ='' where fedirp isnull;
update railroads_tmp set fename ='' where fename isnull;
update railroads_tmp set fetype ='' where fetype isnull;
update railroads_tmp set fedirs ='' where fedirs isnull;
--make a easy-to-label name
ALTER TABLE railroads_tmp add column name text;
UPDATE railroads_tmp SET name =trim( both ' ' from fedirp || ' ' || fename || ' ' || fetype || ' '|| fedirs) ;
-- lengths
ALTER TABLE railroads_tmp add column length_m float8;
update railroads_tmp set length_m =
length2d_spheroid (the_geom, 'SPHEROID["GRS_1980",6378137,298.257222101]' )
;
CREATE TABLE railroads AS
SELECT the_geom, cfcc, cfcc_1,cfcc_2,cfcc_3,module, tlid, name, length_m
FROM railroads_tmp;
CREATE INDEX railroads_idx_module on railroads (module);
CREATE INDEX railroads_idx_moduleid on railroads (module,tlid);
CREATE INDEX railroads_idx_spatial on railroads using gist (the_geom gist_geometry_ops);
VACUUM ANALYSE railroads;
INSERT INTO geometry_columns values ('','public','railroads','the_geom',2,1,'GEOMETRY');
DROP TABLE railroads_tmp;
From the TIGER manual:
Road With Category Unknown Source
Materials do not allow determination of the road category.
CFCC |
Description |
A00 |
Road feature; classification unknown or not elsewhere classified |
Primary Highway With Limited Access Interstate
Highways and some toll highways are in this category (A1) and are distinguished by the presence
of interchanges. These highways are accessed by way of ramps and have
multiple lanes of traffic. The opposing traffic lanes are divided by a
median strip. The TIGER/Line files may depict these opposing traffic
lanes as two distinct lines in which case, the road is called separated.
CFCC |
Description |
A11 |
Primary road with limited access or interstate highway, unseparated |
A12 |
Primary road with limited access or interstate highway, unseparated, in tunnel |
A13 |
Primary road with limited access or interstate highway, unseparated,underpassing |
A14 |
Primary road with limited access or interstate highway, unseparated, with rail line in center |
A15 |
Primary road with limited access or interstate highway, separated |
A16 |
Primary road with limited access or interstate highway, separated, in tunnel |
A17 |
Primary road with limited access or interstate highway, separated,underpassing |
A18 |
Primary road with limited access or interstate highway, separated, withrail line in center |
A19 |
Primary road with limited access or interstate highway, bridge |
Primary Road Without Limited Access
This category (A2) includes nationally
and regionally important highways that do not have limited access
as required by category A1. It consists mainly of US highways, but may
include some state highways and county highways that connect cities and
larger towns. A road in this category must be hard-surface (concrete or
asphalt). It has intersections with other roads, may be divided or undivided,
and have multi-lane or single-lane characteristics.
CFCC |
Description |
A21 |
Primary road without limited access, US highways, unseparated |
A22 |
Primary road without limited access, US highways, unseparated, in tunnel |
A23 |
Primary road without limited access, US highways, unseparated, underpassing |
A24 |
Primary road without limited access, US highways, unseparated, with rail line in center |
A25 |
Primary road without limited access, US highways, separated |
A26 |
Primary road without limited access, US highways, separated, in tunnel |
A27 |
Primary road without limited access, US highways, separated, underpassing |
A28 |
Primary road without limited access, US highways, separated, with rail line in center |
A29 |
Primary road without limited access, US highways, bridge |
Secondary and Connecting Road
This category (A3) includes mostly
state highways, but may include some county highways that connect
smaller towns, subdivisions, and neighborhoods. The roads in this
category generally are smaller than roads in Category A2, must be hardsurface
(concrete or asphalt), and are usually undivided with single-lane
characteristics. These roads usually have a local name along with a route
number and intersect with many other roads and driveways.
CFCC |
Description |
A31 |
Secondary and connecting road, state and county highways, unseparated |
A32 |
Secondary and connecting road, state and county highways, unseparated, in tunnel |
A33 |
Secondary and connecting road, state and county highways, unseparated, underpassing |
A34 |
Secondary and connecting road, state and county highways, unseparated, with rail line in center |
A35 |
Secondary and connecting road, state and county highways, separated |
A36 |
Secondary and connecting road, state and county highways, separated, in tunnel |
A37 |
Secondary and connecting road, state and county highways, separated, underpassing |
A38 |
Secondary and connecting road, state and county highway, separated, with rail line in center |
A39 |
Secondary and connecting road, state and county highways, bridge |
Local, Neighborhood, and Rural Road
A road in this category (A4) is used
for local traffic and usually has a single lane of traffic in each direction. In an
urban area, this feature is a neighborhood road and street that is not a
thorough-fare belonging in categories A2 or A3. In a rural area, this is a
short-distance road connecting the smallest towns; the road may or may not
have a state or county route number. Scenic park roads, unimproved or
unpaved roads, and industrial roads are included in this category. Most
roads in the United States are classified as A4 roads.
CFCC |
Description |
A41 |
Local, neighborhood, and rural road, city street, unseparated |
A42 |
Local, neighborhood, and rural road, city street, unseparated, in tunnel |
A43 |
Local, neighborhood, and rural road, city street, unseparated, underpassing |
A44 |
Local, neighborhood, and rural road, city street, unseparated, with rail line in center |
A45 |
Local, neighborhood, and rural road, city street, separated |
A46 |
Local, neighborhood, and rural road, city street, separated, in tunnel |
A47 |
Local, neighborhood, and rural road, city street, separated, underpassing |
A48 |
Local, neighborhood, and rural road, city street, separated, with rail line in center |
A49 |
Local, neighborhood, and rural road, city street, bridge |
Vehicular Trail
A road in this category (A5) is usable only by four-wheel
drive vehicles, is usually a one-lane dirt trail, and is found almost exclusively
in very rural areas. Sometimes the road is called a fire road or
logging road and may include an abandoned railroad grade where the
tracks have been removed. Minor, unpaved roads usable by ordinary cars
and trucks belong in category A4, not A5.
CFCC |
Description |
A51 |
Vehicular trail, road passable only by 4WD vehicle, unseparated |
A52 |
Vehicular trail, road passable only by 4WD vehicle, unseparated, in tunnel |
A53 |
Vehicular trail, road passable only by 4WD vehicle, unseparated, underpassing |
Road with Special Characteristics
This category (A6) includes roads,
portions of a road, intersections of a road, or the ends of a road that are
parts of the vehicular highway system and have separately identifiable
characteristics.
CFCC |
Description |
A60 |
Special road feature, major category used when the minor category could not be determined |
A61 |
Cul-de-sac, the closed end of a road that forms a loop or turn-around |
A62 |
Traffic circle, the portion of a road or intersection of roads forming a roundabout |
A63 |
Access ramp, the portion of a road that forms a cloverleaf or limitedaccess interchange |
A64 |
Service drive, the road or portion of a road that provides access to
businesses, facilities, and rest areas along a limited-access highway; this
frontage road may intersect other roads and be named |
A65 |
Ferry crossing, the representation of a route over water that connects
roads on opposite shores; used by ships carrying automobiles or people |
A66 |
Gated barrier to travel |
A67 |
Toll booth barrier to travel |
Road as Other Thoroughfare
A road in this category (A7) is not part of
the vehicular highway system. It is used by bicyclists or pedestrians, and
is typically inaccessible to mainstream motor traffic except for privateowner
and service vehicles. This category includes foot and hiking trails
located on park and forest land, as well as stairs or walkways that follow
a road right-of-way and have names similar to road names.
CFCC |
Description |
A70 |
Other thoroughfare, major category used when the minor category could not be determined |
A71 |
Walkway or trail for pedestrians, usually unnamed |
A72 |
Stairway, stepped road for pedestrians, usually unnamed |
A73 |
Alley, road for service vehicles, usually unnamed, located at the rear of buildings and property |
A74 |
Private road or drive for service vehicles, usually privately owned and
unnamed. Primary type of use is for access to oil rigs, farms, or ranches |
A75 |
Internal U.S. Census Bureau use |
Feature Class B, Railroad
Railroad With Category Unknown Source materials do not allow
determination of the railroad category.
B00 Railroad feature; classification unknown or not elsewhere classified
Railroad Main Line A railroad in this category is the primary track that
provides service between destinations. A main line track often carries the
name of the owning and operating railroad company.
CFCC |
Description |
B11 |
Railroad main track, not in tunnel or underpassing |
B12 |
Railroad main track, in tunnel |
B13 |
Railroad main track, underpassing |
B14 |
Abandoned/inactive rail line with tracks present |
B15 |
Abandoned rail line with grade, but no tracks |
B16 |
Abandoned rail line with track and grade information unknown |
B19 |
Railroad main track, bridge |
Railroad Spur
A railroad in this category is the track that leaves the main
track, ending in an industrial park, factory, or warehouse area, or forming
a siding along the main track.
CFCC |
Description |
B21 |
Railroad spur track, not in tunnel or underpassing |
B22 |
Railroad spur track, in tunnel |
B23 |
Railroad spur track, underpassing |
B29 |
Railroad spur track, bridge |
Railroad Yard
A railroad yard track has parallel tracks that form a
working area for the railroad company. Train cars and engines are
repaired, switched, and dispatched from a yard.
CFCC |
Description |
B31 |
Railroad yard track, not in tunnel or underpassing |
B32 |
Railroad yard track, in tunnel |
B33 |
Railroad yard track, underpassing |
B39 |
Railroad yard track, bridge |
Railroad with Special Characteristics
A railroad or portions of a railroad
track that are parts of the railroad system and have separately
identifiable characteristics.
CFCC |
Description |
B40 |
Railroad ferry crossing, the representation of a route over water used
by ships carrying train cars to connecting railroads on opposite shores. These
are primarily located on the Great Lakes. |
Railroad as Other Thoroughfare
A rail line that is not part of the railroad
system. This category is for a specialized rail line or railway that is
typically inaccessible to mainstream railroad traffic.
CFCC |
Description |
B50 |
Other rail line; major category used alone when the minor category could
not be determined |
B51 |
Carline, a track for streetcars, trolleys, and other mass transit rail systems;
used when the carline is not part of the road right-of-way |
B52 |
Cog railroad, incline railway, or logging tram |
SELECT cfcc, count(*) FROM roads GROUP BY cfcc ORDER BY cfcc;
SELECT cfcc, count(*) FROM railroads GROUP BY cfcc ORDER BY cfcc;
H2. Adding altname to roads
first we convert the altname table from
ogc_fid | wkb_geometry | module | tlid | rtsq | feat
---------+--------------+----------+----------+------+------------------------
64198 | | TGR01083 | 95250591 | 1 | {1250,452,593,363,306}
64199 | | TGR01083 | 95250591 | 2 | {1782,1784}
into (combining the feat list in each):
ogc_fid | wkb_geometry | module | tlid | rtsq | feat
---------+--------------+----------+----------+------+------------------------
64198 | | TGR01083 | 95250591 | 1 | {1250,452,593,363,306,1782,1784}
So, to combine these rows (there's 130 of them):
begin;
update altname set feat = feat||(select dm2.feat from altname dm2 where dm2.module=altname.module and altname.tlid = dm2.tlid and dm2.rtsq = 1)
WHERE rtsq =2;
delete from altname
WHERE rtsq =1
AND module||tlid in (select module||tlid from altname where rtsq=2);
commit;
Great, now we're going to add all the altname in:
alter table altname add column altname1 text;
alter table altname add column altname2 text;
alter table altname add column altname3 text;
alter table altname add column altname4 text;
alter table altname add column altname5 text;
alter table altname add column altname6 text;
alter table altname add column altname7 text;
alter table altname add column altname8 text;
alter table altname add column altname9 text;
-- (this is also done in major_roads, so dont do it twice)
--
update featureids set fedirp ='' where fedirp isnull;
update featureids set fename ='' where fename isnull;
update featureids set fetype ='' where fetype isnull;
update featureids set fedirs ='' where fedirs isnull;
alter table featureids add full_name text;
update featureids set full_name= trim( both ' ' from fedirp || ' ' || fename || ' ' || fetype || ' '|| fedirs) ;
CREATE INDEX featids_indx_mod_feat on featureids (module,feat);
vacuum analyse featureids;
--
update altname
set altname9 =
(select full_name from featureids where featureids.module = altname.module and featureids.feat= altname.feat[9])
where array_upper(feat,1) >=9;
update altname
set altname8 =
(select full_name from featureids where featureids.module = altname.module and featureids.feat= altname.feat[8])
where array_upper(feat,1) >=8;
update altname
set altname7 =
(select full_name from featureids where featureids.module = altname.module and featureids.feat= altname.feat[7])
where array_upper(feat,1) >=7;
update altname
set altname6 =
(select full_name from featureids where featureids.module = altname.module and featureids.feat= altname.feat[6])
where array_upper(feat,1) >=6;
update altname
set altname5 =
(select full_name from featureids where featureids.module = altname.module and featureids.feat= altname.feat[5])
where array_upper(feat,1) >=5;
update altname
set altname4 =
(select full_name from featureids where featureids.module = altname.module and featureids.feat= altname.feat[4])
where array_upper(feat,1) >=4;
update altname
set altname3 =
(select full_name from featureids where featureids.module = altname.module and featureids.feat= altname.feat[3])
where array_upper(feat,1) >=3;
update altname
set altname2 =
(select full_name from featureids where featureids.module = altname.module and featureids.feat= altname.feat[2])
where array_upper(feat,1) >=2;
update altname
set altname1 =
(select full_name from featureids where featureids.module = altname.module and featureids.feat= altname.feat[1])
where array_upper(feat,1) >=1;
Okay, now we have altname setup so its easy to use. We now transfer the data over to roads.
--
--WARNING, this takes a few hours!
--
CREATE TABLE roads2 AS
SELECT roads.the_geom, roads.cfcc, roads.cfcc_1, roads.cfcc_2, roads.cfcc_3,
roads.module, roads.tlid, roads.name, roads.length_m,
altname1,altname2,altname3,altname4,altname5,altname6,altname7,altname8,altname9
FROM
roads LEFT JOIN altname ON
(
(roads.module = altname.module)
AND
(roads.tlid = altname.tlid)
);
alter table roads2 rename column the_geom to gen_full;
alter table roads2 add column gen_1 geometry;
update roads2 set gen_1 = simplify(gen_full,0.0001);
delete from geometry_columns where f_table_name = 'roads';
INSERT INTO geometry_columns values ('','public','roads','gen_full',2,1,'GEOMETRY');
INSERT INTO geometry_columns values ('','public','roads','gen_1',2,1,'GEOMETRY');
alter table roads2 add primary key (module,tlid);
create index "roads_idx_module" on roads2 (module);
create index "roads_idx_moduleid" on roads2 (module,tlid);
create index "roads_idx_spatial" on roads2 using gist (gen_full gist_geometry_ops);
create index "roads_idx_spatia2l" on roads2 using gist (gen_1 gist_geometry_ops);
vacuum analyse roads2;
-- kill the olds roads table
DROP TABLE roads;
--replace
ALTER TABLE roads2 rename to roads;
The indexes in the alternate name queries for the roads2 table are in use, they should be changed to "roads2_idx_module", etc...
John Cole

Posted by at Apr 18, 2006 15:04
|
|